var pool = require("./config/db.js"),
    markdown = require('markdown').markdown;

function Hotel(name,city_id,hotel_address,rates_added){
    this.name = name;
    this.city_id = city_id;
    this.hotel_address = hotel_address;
    this.rates_added = rates_added;
};

module.exports = Hotel;

//存储一篇文章及其相关信息
Hotel.prototype.save = function(callback){
    var date = new Date();
    //存储各种时间格式，以便以后扩展
    var time ={
        date: date,
        year: date.getFullYear(),
        month: date.getFullYear() + '-' + (date.getMonth() +1),
        day: date.getFullYear() + '-' + (date.getMonth() +1) + date.getDay(),
        minute: date.getFullYear() + '-' + (date.getMonth() +1) + date.getDay()  + date.getHours() +":" + date.getMinutes()<10 ? '0'+ date.getMinutes() : date.getMinutes()
    }
    //要存入数据库的文档
    var hotel = {
        name: this.name,
        city_id:this.city_id,
        hotel_address:this.hotel_address,
        rates_added:this.rates_added
    };
    //打开数据库

};

//读取房间
Hotel.getTen  = function(country_id,page, callback) {
    pool.getConnection(function(err, connection) {
        connection.query('SELECT * FROM `hotel`', function (err, rows, fields) {
            if (err) {
                return callback(err);//失败！返回 err
            }
            callback(null,rows[0]);
        });
    });
};

Hotel.getOne = function(hotel_id,callback){

}

Hotel.edit = function(hotel_id,callback){

}

Hotel.update = function(name,city_id,hotel_address,callback){

}

Hotel.remove =function(hotel_id, callback){

}

//get城市
Hotel.getCity = function(callback){

}

//返回所有标签
Hotel.getCounty = function(callback){

}

Hotel.search = function(keyword,callback){

}